import { Injectable } from '@nestjs/common';
import { DeleteResult, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Menu } from './menu.entity';
import { MENU_LIST } from './menuData';
// import { CreateUserDto } from './create-user.dto';

@Injectable()
export class MenuService {
  constructor(
    @InjectRepository(Menu)
    private readonly menuRepository: Repository<Menu>,
  ) {
    
  }
 
  findeAll():Promise<any>{
    // return Promise.resolve(MENU_LIST);
    // return this.menuRepository.findBy({actvie:1});
    const QUER_ALL_SQL='select * from menu where actvie=1 order by id asc';
    return this.menuRepository.query(QUER_ALL_SQL);
  }
  getMenuallList():Promise<any>{
    // return Promise.resolve(MENU_LIST);
    // return this.menuRepository.findBy({actvie:1});
    const sql='select * from menu  order by id asc';
    return this.menuRepository.query(sql);
  }
  create(body){
    return this.menuRepository.save(body.data||body);
    
  }
  update(body){
    const id=body?.data?.id ||body?.id;
    const data=body.data||body;
    return this.menuRepository.update(id,data);
    
  }
}
